$(function() {
	$("#termsDialog").dialog({autoOpen:false, width:760, height:500});
	$("#showTerms").click(function()
	{
		$("#termsDialog").dialog("open");
	});
	$( "#theDate" ).datepicker({
		changeMonth: true,
		changeYear: true,
		yearRange: '1940:2004' 
	});
	$( "#theDate" ).datepicker( "option", "dateFormat", "yy-mm-dd" );
	$("#tabular").tabs();
	if($.browser.opera) 
	{
		$("#globe").css("margin-top", "-200");
		$("#registerTab").click(function()
		{
			$("#globe").css("margin-top", "-333");
		});
		$("#loginTab").click(function()
		{
			$("#globe").css("margin-top", "-200");
		});
    }
	/*if($.browser.msie) 
	{
		$("#globe").css("margin-top", "-230");*/
		$("#logo").css("border", "0");/*
		$("#topBar").css("border-bottom-style", "solid");
		$("#topBar").css("border-bottom-width", "2px");
		$("#registerTab").click(function()
		{
			$("#globe").css("margin-top", "-372");
		});
		$("#loginTab").click(function()
		{
			$("#globe").css("margin-top", "-230");
		});
    }*/
	if($.browser.safari)
	{
		$(".ui-widget-content").css("background-color", "#5f5964");
	}
	if($.browser.mozilla)
	{
		$(".ui-widget-content").css("background-color", "#5f5964");
	}
	$("#registerForm").submit(function(event)
	{
		var firstName = $("#firstName").val();
		var length = firstName.length;
		var specSigns = 0;
		var firstNameEr = 0;
		var notAg = 0;
		for(var i = 0; i<length; i++)
				{
					if((firstName[i]<'A')||(firstName[i]>'z'))
					{
						specSigns++;
					}
				}
				if(specSigns > 0)
				{
					$("#firstName").css("border", "1pt solid red");
					$("#firstName").val("");
					$("#firstNameError").css("display", "inline");
					firstNameEr++;
				}
				else
				{
					$("#firstName").css("border", "2px solid #999");
					$("#firstNameError").css("display", "none");
					firstNameEr = 0;
				}
		var lastName = $("#lastName").val();
		var lastLength = lastName.length;
		var lastSpecSigns = 0;
		var lastNameEr = 0;
		for(var i = 0; i<lastLength; i++)
				{
					if((lastName[i]<'A')||(lastName[i]>'z'))
					{
						lastSpecSigns++;
					}
				}
				if(lastSpecSigns > 0)
				{
					$("#lastName").css("border", "1pt solid red");
					$("#lastName").val("");
					$("#lastNameError").css("display", "inline");
					lastNameEr++;
				}
				else
				{
					$("#lastName").css("border", "2px solid #999");
					$("#lastNameError").css("display", "none");
					lastNameEr = 0;
				}
				
		var passEr = 0;
		if($("#pass").val() != $("#rePass").val())
		{
			passEr++;
			$("#pass").css("border", "1pt solid red");
			$("#rePass").css("border", "1pt solid red");
			$("#pass").val("");
			$("#rePass").val("");
			$("#passwordError").css("display", "inline");
		}
		else
		{
			passEr = 0;
			$("#pass").css("border", "2px solid #999");
			$("#rePass").css("border", "2px solid #999");
			$("#passwordError").css("display", "none");
		}
		var emailEr = 0;
		if($("#email").val() != $("#reEmail").val())
		{
			emailEr++;
			$("#email").css("border", "1pt solid red");
			$("#reEmail").css("border", "1pt solid red");
			$("#email").val("");
			$("#reEmail").val("");
			$("#emailError").css("display", "inline");
		}
		else
		{
			emailEr = 0;
			$("#email").css("border", "2px solid #999");
			$("#reEmail").css("border", "2px solid #999");
			$("#emailError").css("display", "none");
		}
		var bDateEr = 0;
		if($("#theDate").val() == "")
		{
			$("#emptyDate").css("display", "inline");
			$("#theDate").css("border", "1pt solid red");
			bDateEr++;
		}
		else
		{
			$("#emptyDate").css("display", "none");
			$("#theDate").css("border", "2px solid #999");
			bDateEr = 0;
		}
		var emptyFirstNameEr = 0;
		if($("#firstName").val() == "")
		{
			$("#firstNameError").css("display", "inline");
			$("#firstName").css("border", "1pt solid red");
			emptyFirstNameEr++;
		}
		else
		{
			$("#firstNameError").css("display", "none");
			$("#firstName").css("border", "2px solid #999");
			emptyFirstNameEr = 0;
		}
		var emptyLastNameEr = 0;
		if($("#lastName").val() == "")
		{
			$("#lastNameError").css("display", "inline");
			$("#lastName").css("border", "1pt solid red");
			emptyLastNameEr++;
		}
		else
		{
			emptyLastNameEr = 0;
			$("#lastNameError").css("display", "none");
			$("#lastName").css("border", "2px solid #999");
		}
		var emptyPasswordEr = 0;
		if($("#pass").val() == "")
		{
			$("#emptyPassword").css("display", "inline");
			$("#pass").css("border", "1pt solid red");
			emptyPasswordEr++;
		}
		else
		{
			$("#emptyPassword").css("display", "none");
			$("#pass").css("border", "2px solid #999");
			emptyPasswordEr = 0;
		}
		var emptyEmail = 0;
		if($("#email").val() == "")
		{
			$("#emptyEmail").css("display", "inline");
			$("#email").css("border", "1pt solid red");
			emptyEmail++;
		}
		else
		{
			$("#emptyEmail").css("display", "none");
			$("#email").css("border", "2px solid #999");
			emptyEmail = 0;
		}
		if(!$("#termsAgree").is(':checked'))
		{
			$("#dontAgree").css("display", "inline");
			notAg++;
		}
		else
		{
			$("#dontAgree").css("display", "none");
			notAg = 0;
		}
		if((firstNameEr>0)||(lastNameEr>0)||(passEr>0)||(emailEr>0)||(bDateEr>0)||(emptyFirstNameEr>0)||(emptyLastNameEr>0)||(emptyPasswordEr>0)||(emptyEmail>0)||(notAg>0))
		{
			event.preventDefault();
		}
	});

});




































